#include<iostream>
#include<string>
#include<stdlib.h>
#include<algorithm>
#include<memory.h>
using namespace std;

bool isUniqueChars1(string str)
{
	bool char_set[256];
	memset(char_set,0,sizeof(char_set));
	for(int i=0;i<str.length();i++)
	{
		int val=(int)str[i];   //convert char to int.
		if(char_set[val])  return false; 
		char_set[val]=true;
	}
	return true;
}

bool isUniqueChars2(string str)
{
	int a[8];
	for(int i=0;i<str.length();i++)
	{
		int val=(int)str[i];
		int row=val/32,col=val%32;
		if(a[row]&(1<<col))  return false;
		a[row] |= (1<<col);
	}
	return true;
}

bool isUniqueChars3(string str)
{
	int checker=0;
	for(int i=0;i<str.length();i++)
	{
		int val=(int)(str[i]-'a');
		if(checker & (1<<val))   return false;
		checker |= (1<<val);
	}
	return true;
}

bool isUniqueChars4(string str)
{
	for(int i=0;i<str.length();i++)
	{
		for(int j=i+1;j<str.length();j++)
		{
			if(str[i]==str[j])  return false;
		}
	}
	return true;
}

bool isUniqueChars5(string str)
{
	sort(str.begin(),str.end());
	for(int i=0;i<str.length()-1;i++)
	{
		if(str[i]==str[i+1]) return false;
	}
	return true;
}

int main()
{
	string str1="I come from China.";
	string str2="abcdefghijklmnopqrstuvwxyz";
	cout<<"Case 1 : "<<isUniqueChars1(str1)<<","<<isUniqueChars1(str2)<<endl;
	cout<<"Case 2 : "<<isUniqueChars2(str1)<<","<<isUniqueChars2(str2)<<endl;
	cout<<"Case 3 : "<<isUniqueChars3(str1)<<","<<isUniqueChars3(str2)<<endl;
	cout<<"Case 4 : "<<isUniqueChars4(str1)<<","<<isUniqueChars4(str2)<<endl;
	cout<<"Case 5 : "<<isUniqueChars5(str1)<<","<<isUniqueChars5(str2)<<endl;
	return 0;
}








